#ifndef RIBBONS_H
#define RIBBONS_H

#include "Demo.h"
#include "RenderTarget.h"
#include "BitmapFont.h"
#include "VectorBatch.h"
#include "Random.h"
#include "Camera.h"

using namespace Cvekas;

class Ribbons : public TimelineSegment
{
public:
	Ribbons(RendererPtr renderer, VectorBatchPtr vector_batch, SpriteBatchPtr sprite_batch, BitmapFontPtr font);
	~Ribbons();

	virtual void init(boost::weak_ptr<Demo> owner);
	virtual void close();
	
	virtual void update(float t);
	virtual void render(float t);

private:
	Vector3 curve1(float t);
	Vector3 curve2(float t);
	Vector3 curve3(float t);

	Vector3 random_point_in_sphere();

	RenderTargetPtr offscreen_target1;
	RenderTargetPtr offscreen_target2;
	RenderTargetPtr text_target;
	RendererPtr renderer;
	SpriteBatchPtr sprite_batch;
	VectorBatchPtr vector_batch;
	BitmapFontPtr font;

	VertexBufferPtr ribbons_vb;
	EffectPtr ribbons_effect;
	Batch ribbons_batch;

	IndexBufferPtr quads_ib;
	IndexBufferPtr tunnel_ib;
	VertexBufferPtr quads_vb;
	VertexBufferPtr tunnel_vb;
	Batch quads1_batch;
	Batch quads2_batch;
	Batch tunnel1_batch;
	Batch tunnel2_batch;
	EffectPtr quads_effect;
	EffectPtr tunnel_effect;
	EffectPtr default_sprite_effect;
	EffectPtr blured_sprite_effect;
	Texture2DPtr pattern1;

	Random prng;

	SimpleCamera camera;

	std::string text;
};

typedef boost::shared_ptr<Ribbons> RibbonsPtr;

#endif